package com.liuyi.netty.im.lychat.config.base;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.liuyi.rapid.develop.mybatis.plus.base.IBaseService;
import com.liuyi.rapid.develop.tool.resp.Response;
import com.liuyi.rapid.develop.tool.resp.ResponseCall;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;

import java.io.Serializable;

public interface BaseDelController<T, S extends IBaseService<T>> extends BaseController<T, S> {

    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", dataType = "int", name = "id", value = "数据id")
    })
    @ApiOperation(value = "删除", notes = "", httpMethod = "POST", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    @PostMapping("/del/{id}")
    default Response<Void> del(@PathVariable Serializable id) {
        checkDel(id);
        QueryWrapper<T> q = server().q().eq("id", id);
        delThene(q);
        resultDel(id, server().remove(q));
        return ResponseCall.successMsg("删除成功");
    }

    default void delThene(QueryWrapper<T> queryWrapper) {

    }

    default void checkDel(Serializable id) {

    }

    default void resultDel(Serializable id, boolean result) {

    }
}
